﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Demo_Excel列表框.View
{
    /// <summary>
    /// List_1.xaml 的交互逻辑
    /// </summary>
    public partial class List_1 : UserControl
    {
        public List_1()
        {
            InitializeComponent();
            DataContext = ViewModel.ViewModel.GetInstance().m_Model_MainWindow;
        }

        private void button_ClearOneList_Click(object sender, RoutedEventArgs e)
        {
            if (LG.Items.Count != 0 && LG.SelectedIndex != -1)
            {
                var nIndex = LG.SelectedIndex;
                ViewModel.ViewModel.GetInstance().m_Model_MainWindow.m_LG.RemoveAt(nIndex);
                ViewModel.ViewModel.GetInstance().m_Model_MainWindow.LGListSort();
            }
        }

        private void button_Trash_Click(object sender, RoutedEventArgs e) => ViewModel.ViewModel.GetInstance().m_Model_MainWindow.m_LG.Clear();

        private void btn_Add_Click(object sender, RoutedEventArgs e) => ViewModel.ViewModel.GetInstance().m_Model_MainWindow.AddModel("5", "4", "3", "2", "1");

        private void btn_Clear_Click(object sender, RoutedEventArgs e) => ViewModel.ViewModel.GetInstance().m_Model_MainWindow.m_LG.Clear();

    }
}
